package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250224104246CreateMenuPermissionsTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250224104246CreateMenuPermissionsTable) Signature() string {
	return "20250224104246_create_menu_permissions_table"
}

// Up Run the migrations.
func (r *M20250224104246CreateMenuPermissionsTable) Up() error {
	if !facades.Schema().HasTable("menu_permissions") {
		return facades.Schema().Create("menu_permissions", func(table schema.Blueprint) {
			table.UnsignedBigInteger("menu_id")
			table.UnsignedBigInteger("permission_id")
			//table.Foreign("menu_id").References("id").On("menus")
			//table.Foreign("permission_id").References("id").On("permissions")
			table.Index("menu_id", "permission_id")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250224104246CreateMenuPermissionsTable) Down() error {
	return facades.Schema().DropIfExists("menu_permissions")
}
